﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Windows.Forms;

namespace HslCommunication.Controls
{
	/// <summary>
	/// 瓶子控件
	/// </summary>
	// Token: 0x0200016E RID: 366
	public class UserBottle : UserControl
	{
		/// <summary>
		/// 实例化一个新的控件对象
		/// </summary>
		// Token: 0x06001E16 RID: 7702 RVA: 0x00090758 File Offset: 0x0008E958
		public UserBottle()
		{
			this.InitializeComponent();
			this.DoubleBuffered = true;
			this.stringFormat.Alignment = StringAlignment.Center;
			this.stringFormat.LineAlignment = StringAlignment.Center;
		}

		/// <summary>
		/// 获取或设置瓶子的液位值。
		/// </summary>
		// Token: 0x17000621 RID: 1569
		// (get) Token: 0x06001E17 RID: 7703 RVA: 0x000907D4 File Offset: 0x0008E9D4
		// (set) Token: 0x06001E18 RID: 7704 RVA: 0x000907EC File Offset: 0x0008E9EC
		[Browsable(true)]
		[DefaultValue(typeof(double), "60")]
		[Category("外观")]
		public double Value
		{
			get
			{
				return this.value;
			}
			set
			{
				bool flag = value >= 0.0 && value <= 100.0;
				if (flag)
				{
					this.value = value;
					base.Invalidate();
				}
			}
		}

		/// <summary>
		/// 获取或设置瓶子是否处于打开的状态。
		/// </summary>
		// Token: 0x17000622 RID: 1570
		// (get) Token: 0x06001E19 RID: 7705 RVA: 0x0009082C File Offset: 0x0008EA2C
		// (set) Token: 0x06001E1A RID: 7706 RVA: 0x00090844 File Offset: 0x0008EA44
		[Browsable(true)]
		[DefaultValue(typeof(bool), "false")]
		[Category("外观")]
		public bool IsOpen
		{
			get
			{
				return this.isOpen;
			}
			set
			{
				this.isOpen = value;
				base.Invalidate();
			}
		}

		/// <summary>
		/// 获取或设置瓶子的标签信息，用于绘制在瓶子上的信息。
		/// </summary>
		// Token: 0x17000623 RID: 1571
		// (get) Token: 0x06001E1B RID: 7707 RVA: 0x00090858 File Offset: 0x0008EA58
		// (set) Token: 0x06001E1C RID: 7708 RVA: 0x00090870 File Offset: 0x0008EA70
		[Browsable(true)]
		[DefaultValue(typeof(string), "")]
		[Category("外观")]
		public string BottleTag
		{
			get
			{
				return this.bottleTag;
			}
			set
			{
				this.bottleTag = value;
				base.Invalidate();
			}
		}

		/// <summary>
		/// 获取或设置瓶子的备注信息，用于绘制在瓶子顶部的信息。
		/// </summary>
		// Token: 0x17000624 RID: 1572
		// (get) Token: 0x06001E1D RID: 7709 RVA: 0x00090884 File Offset: 0x0008EA84
		// (set) Token: 0x06001E1E RID: 7710 RVA: 0x0009089C File Offset: 0x0008EA9C
		[Browsable(true)]
		[DefaultValue(typeof(string), "原料1")]
		[Category("外观")]
		public string HeadTag
		{
			get
			{
				return this.headTag;
			}
			set
			{
				this.headTag = value;
				base.Invalidate();
			}
		}

		/// <summary>
		/// 重写消息处理机制
		/// </summary>
		/// <param name="m">系统消息</param>
		// Token: 0x06001E1F RID: 7711 RVA: 0x000908B0 File Offset: 0x0008EAB0
		protected override void WndProc(ref Message m)
		{
			bool flag = m.Msg == 20;
			if (!flag)
			{
				base.WndProc(ref m);
			}
		}

		/// <summary>
		/// 重新绘制界面图形
		/// </summary>
		/// <param name="e">绘制消息</param>
		// Token: 0x06001E20 RID: 7712 RVA: 0x000908D8 File Offset: 0x0008EAD8
		protected override void OnPaint(PaintEventArgs e)
		{
			bool flag = !Authorization.nzugaydgwadawdibbas();
			if (!flag)
			{
				Graphics graphics = e.Graphics;
				graphics.SmoothingMode = SmoothingMode.HighQuality;
				graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
				bool flag2 = base.Width < 15 || base.Height < 15;
				if (!flag2)
				{
					int num = base.Width / 2;
					int num2 = base.Height - base.Width - (base.Height - base.Width - 20) * Convert.ToInt32(this.value) / 100;
					GraphicsPath graphicsPath = new GraphicsPath();
					graphicsPath.AddPolygon(new Point[]
					{
						new Point(0, 20),
						new Point(0, base.Height - base.Width),
						new Point(num + 1, base.Height - 8),
						new Point(num + 1, 20),
						new Point(0, 20)
					});
					Brush brush = new LinearGradientBrush(new Point(0, 20), new Point(num + 1, 20), Color.FromArgb(142, 196, 216), Color.FromArgb(240, 240, 240));
					graphics.FillPath(brush, graphicsPath);
					graphicsPath.Reset();
					graphicsPath.AddPolygon(new Point[]
					{
						new Point(num, 20),
						new Point(num, base.Height - 8),
						new Point(base.Width - 1, base.Height - base.Width),
						new Point(base.Width - 1, 20),
						new Point(num, 20)
					});
					brush.Dispose();
					brush = new LinearGradientBrush(new Point(num - 1, 20), new Point(base.Width - 1, 20), Color.FromArgb(240, 240, 240), Color.FromArgb(142, 196, 216));
					graphics.FillPath(brush, graphicsPath);
					brush.Dispose();
					brush = new SolidBrush(Color.FromArgb(151, 232, 244));
					graphics.FillEllipse(brush, 1, 17, base.Width - 3, 6);
					brush.Dispose();
					graphicsPath.Reset();
					graphicsPath.AddPolygon(new Point[]
					{
						new Point(0, num2),
						new Point(0, base.Height - base.Width),
						new Point(num + 1, base.Height - 8),
						new Point(num + 1, num2),
						new Point(0, num2)
					});
					brush = new LinearGradientBrush(new Point(0, 20), new Point(num + 1, 20), Color.FromArgb(194, 190, 77), Color.FromArgb(226, 221, 98));
					graphics.FillPath(brush, graphicsPath);
					brush.Dispose();
					graphicsPath.Reset();
					graphicsPath.AddPolygon(new Point[]
					{
						new Point(num, num2),
						new Point(num, base.Height - 8),
						new Point(base.Width - 1, base.Height - base.Width),
						new Point(base.Width - 1, num2),
						new Point(num, num2)
					});
					brush = new LinearGradientBrush(new Point(num - 1, 20), new Point(base.Width - 1, 20), Color.FromArgb(226, 221, 98), Color.FromArgb(194, 190, 77));
					graphics.FillPath(brush, graphicsPath);
					brush.Dispose();
					graphicsPath.Dispose();
					brush = new SolidBrush(Color.FromArgb(243, 245, 139));
					graphics.FillEllipse(brush, 1, num2 - 3, base.Width - 3, 6);
					brush.Dispose();
					graphics.FillEllipse(Brushes.White, 4, base.Height - base.Width, base.Width - 9, base.Width - 9);
					Pen pen = new Pen(Color.Gray, 3f);
					bool flag3 = this.isOpen;
					if (flag3)
					{
						pen.Color = Color.LimeGreen;
					}
					graphics.DrawEllipse(pen, 4, base.Height - base.Width, base.Width - 9, base.Width - 9);
					graphics.FillEllipse(this.isOpen ? Brushes.LimeGreen : Brushes.Gray, 8, base.Height - base.Width + 4, base.Width - 17, base.Width - 17);
					pen.Dispose();
					bool flag4 = !string.IsNullOrEmpty(this.bottleTag);
					if (flag4)
					{
						graphics.DrawString(this.bottleTag, this.Font, Brushes.Gray, new Rectangle(-10, 26, base.Width + 20, 20), this.stringFormat);
					}
					bool flag5 = !string.IsNullOrEmpty(this.headTag);
					if (flag5)
					{
						graphics.DrawString(this.headTag, this.Font, Brushes.DimGray, new Rectangle(-10, 0, base.Width + 20, 20), this.stringFormat);
					}
				}
			}
		}

		// Token: 0x06001E21 RID: 7713 RVA: 0x00009AA1 File Offset: 0x00007CA1
		private void UserBottle_Paint(object sender, PaintEventArgs e)
		{
		}

		/// <summary> 
		/// 清理所有正在使用的资源。
		/// </summary>
		/// <param name="disposing">如果应释放托管资源，为 true；否则为 false。</param>
		// Token: 0x06001E22 RID: 7714 RVA: 0x00090E6C File Offset: 0x0008F06C
		protected override void Dispose(bool disposing)
		{
			bool flag = disposing && this.components != null;
			if (flag)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}

		/// <summary> 
		/// 设计器支持所需的方法 - 不要修改
		/// 使用代码编辑器修改此方法的内容。
		/// </summary>
		// Token: 0x06001E23 RID: 7715 RVA: 0x00090EA4 File Offset: 0x0008F0A4
		private void InitializeComponent()
		{
			base.SuspendLayout();
			base.AutoScaleDimensions = new SizeF(6f, 12f);
			base.AutoScaleMode = AutoScaleMode.Font;
			this.BackColor = Color.Transparent;
			base.Name = "UserBottle";
			base.Size = new Size(66, 172);
			base.Paint += this.UserBottle_Paint;
			base.ResumeLayout(false);
		}

		// Token: 0x04000698 RID: 1688
		private double value = 50.0;

		// Token: 0x04000699 RID: 1689
		private bool isOpen = false;

		// Token: 0x0400069A RID: 1690
		private string bottleTag = "";

		// Token: 0x0400069B RID: 1691
		private StringFormat stringFormat = new StringFormat();

		// Token: 0x0400069C RID: 1692
		private string headTag = "原料1";

		/// <summary> 
		/// 必需的设计器变量。
		/// </summary>
		// Token: 0x0400069D RID: 1693
		private IContainer components = null;
	}
}
